﻿@using PagedList.Mvc
@model PagedList.IPagedList<TicketDesk.Web.Client.Models.UserAccountInfoViewModel>
@{
    var ajaxPagerOptions = new AjaxOptions() { HttpMethod = "GET", UpdateTargetId = "userListBody", OnBegin = "adminUsers.paging.beginChangePage", OnSuccess = "adminUsers.completeChangeList", OnFailure = "adminUsers.completeChangeList" };
}
<div id="userListBody">
    <div class="panel panel-default">
        <div class="panel-body" style="padding: 0;">
            <div class="table-responsive">
                <table class="table table-striped table-condensed table-hover ">
                    <tr>
                        <th>
                            User
                        </th>
                        <th>
                            Roles
                        </th>
                        <th>
                            Status
                        </th>
                    </tr>
                    @foreach (var account in Model)
                    {
                        <tr class="clickable">
                            <td>
                                <a href="@Url.Action("Edit", "UserAdministration", new {id = account.User.Id})">
                                    @account.User.DisplayName (@account.User.Email)
                                </a>
                            </td>
                            <td>
                                <ul class="list-unstyled">
                                    @foreach (var role in account.GetRoleNames(ViewBag.AllRolesList))
                                    {
                                        <li class="label label-default">@role</li>
                                    }
                                </ul>
                            </td>
                            <td>
                                <i class="fa fa-2x @(account.IsLocked ? "fa-lock text-danger" : "fa-unlock")"></i>
                            </td>
                        </tr>
                    }
                </table>
            </div>

        </div>
        <div class="panel-footer">
            @Html.PagedListPager(Model, page => Url.Action("PageList", new { page }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(ajaxPagerOptions))
        </div>
    </div>
</div>
